# import requests
# import os,django

# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'iot.settings')
# django.setup()
# from apps.tcpserver.events import SettingNetWorkEventHandle, WriteConfigItemHandle



# response = requests.options('http://106.54.240.219:8000/v1/api/user/login')

# print(response.headers)

# '''
# 55 aa 00 41 00 00 44 1d 00 01 00 01 03 0b 01 33 00 33 01 07 01 00 30 30 30 30 30 30 30 30 30 30 30 30 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 03 05 01 00 00 00 cc aa 55
# 55 aa 00 41 00 00 fd 9a 00 01 00 01 03 0b 01 33 00 33 00 00 00 01 31 30 33 39 35 38 32 32 33 39 35 38 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 05 01 00 00 00 cc aa 55
# '''

# WriteConfigItemHandle()(
#   None,
#   {
#     'msg':{
#       'item': 'remote_network',
#       'subitem': 'remote_ips',
#       'data':[
#         {
#           'start': 1,
#           'code': 1,
#           'status': 1,
#           'addr': '106.54.240.219',
#           'port': 6000
#         }
#       ]
#     }
#   },

# )

'''

55 aa 00 34 00 00 f4 b4 00 01 00 01 03 04 00 54 00 26 01 01 01 31 30 36 2e 35 34 2e 32 34 30 2e 32 31 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 70 17 cc aa 55
55 AA 
00 6B 
00 00 A3 9F 
00 01 
00 01 
1E 
1D 
00 

25 70 00 5F 
00 
01 
00 
04 00 00 00 
00 25 70 00 5F 
00 02 00 04 00 00 00 00 25 70 00 5F 00 03 00 04 00 00 00 00 25 70 00 5F 00 04 00 04 00 00 00 00 25 70 00 5F 00 05 00 04 00 00 00 00 25 70 00 5F 00 06 00 04 00 00 00 00 25 70 00 5F 00 07 00 04 00 00 00 00 25 70 00 5F 00 08 00 04 00 00 00 00 DD AA 55

55 AA 

00 6B 
00 00 6C 28 
00 01 
00 01 

1E 读取当前输出状态响应

1D 本次响应对应请求的净荷类型号

00 0：成功

20 输出种类
8F 输出编号
00 5F 00 01 输出编号数据
00 04 01 00 00 00
20 8F 00 5F 00 02 
00 04 01 00 00 00 
20 8F 00 5F 00 03 
00 04 01 00 00 00 
20 8F 00 5F 00 04 
00 04 00 00 00 00 
20 8F 00 5F 00 05 
00 04 00 00 00 00 
20 8F 00 5F 00 06 
00 04 00 00 00 00 
20 8F 00 5F 00 07 
00 04 00 00 00 00 
20 8F 00 5F 00 08 
00 04 00 00 00 00 
DD AA 55


55 AA 00 6B 00 00 6C 28 00 01 00 01 1E 1D 
00 
20 8F 00 5F 
00 
01 
00 
04 01 00 00 
00 20 8F 00 5F 00 02 00 04 01 00 00 00 20 8F 00 5F 00 03 00 04 01 00 00 00 20 8F 00 5F 00 04 00 04 00 00 00 00 20 8F 00 5F 00 05 00 04 00 00 00 00 20 8F 00 5F 00 06 00 04 00 00 00 00 20 8F 00 5F 00 07 00 04 00 00 00 00 20 8F 00 5F 00 08 00 04 00 00 00 00 DD AA 55



55 aa 00 0f 00 00 6b 61 00 01 00 01 1f 00 01 00 00 00 00 cc aa 55

55 aa 00 0f 00 00 a0 b5 00 01 00 01 1f 00 02 00 00 00 01 cc aa 55

55 aa 00 0f 00 01 08 2b 00 01 00 01 1f 00 03 00 00 00 00 cc aa 55

55 aa 00 0f 00 01 65 55 00 01 00 01 1f 00 04 00 00 00 01 cc aa 55

55 aa 00 0f 00 01 5b 67 00 01 00 01 1f 00 05 00 00 00 01 cc aa 55 

55 aa 00 0f 00 01 6a 06 00 01 00 01 1f 00 06 00 00 00 01 cc aa 55

55 aa 00 0f 00 00 e8 fd 00 01 00 01 1f 00 07 00 00 00 01 cc aa 55

55 aa 00 0f 00 00 98 4b 00 01 00 01 1f 00 08 00 00 00 01 cc aa 55 

55 AA 
00 69 
00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 77 13 03 5F 01 01 00 03 00 00 B0 41 76 13 03 5F 01 02 00 03 00 00 00 41 00 00 00 00 02 01 00 03 00 00 00 00 00 00 00 00 02 02 00 03 00 00 00 00 
00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 55 aa 00 69 00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 
DD 
AA 55

55 AA 00 69 00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 93 12 03 5F 01 01 00 03 00 00 A0 41 93 12 03 5F 01 02 00 03 00 00 E0 40 00 00 00 00 02 01 00 03 00 00 00 00 00 00 00 00 02 02 00 03 00 00 00 00 DD AA 55
55 AA 00 69 00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 D9 24 03 5F 01 01 00 03 00 00 B0 41 D8 24 03 5F 01 02 00 03 00 00 E0 40 00 00 00 00 02 01 00 03 00 00 00 00 00 00 00 00 02 02 00 03 00 00 00 00 DD AA 55
55 aa 00 77 00 00 00 00 00 01 00 01 09 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 00 32 30 20 37 20 36 31 32 20 30 35 37 dd aa 55 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 dd aa 55 
55 aa 00 69 00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 55 aa 00 69 00 00 00 00 00 01 00 01 13 00 00 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 00 00 00 00 03 00 04 00 00 00 00 00 00 00 00 00 04 00 04 00 00 00 00 79 12 03 5f 01 01 00 03 00 00 98 41 79 12 03 5f 01 02 00 03 00 00 e0 40 00 00 00 00 02 01 00 03 00 00 00 00 00 00 00 00 02 02 00 03 00 00 00 00 dd aa 55

55 AA 01 A4 00 01 14 C4 00 07 00 01 06 05 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 01 00 30 00 00 00 00 00 00 00 00 30 30 30 01 01 01 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 01 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 05 01 00 00 00 00 00 00 01 30 34 35 32 31 35 31 38 35 32 31 35 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 07 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 01 31 30 33 39 35 38 32 32 33 39 35 38 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 05 01 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DD AA 55

55 AA 01 A3 00 01 14 C4 00 07 00 02 06 05 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DD AA 55







55 AA 00 41 00 00 2F D4 00 01 00 01 03 0B 00 01 00 33 01 01 01 01 30 36 34 37 33 38 32 33 34 38 34 33 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 CC AA 55

55 AA  
00 41 
00 00 2F D4 
00 01 
00 01 
03 
0B 
00 01 
00 33 
01 
01 
01 
01 
30 36 34 37 33 38 
32 33 34 38 34 33 
00 
01 
00 
00 
00 
00 
00 00 00 00 
00 00 00 00 
00 
00 
01 
00 
00 
00 
00 
00 00 00 00 
00 00 00 00 
01 
01 
01 00 00 00 
CC AA 55

 55 aa 00 0f 00 00 ac 1c 00 01 00 01 1f 00 05 01 00 00 00 cc aa 55

55 aa 00 41 00 00 b5 14 00 01 00 01 03 0b 00 34 00 33 01 02 01 01 30 30 33 35 35 35 32 33 33 35 35 35 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 cc aa 55
'''



import pwd,grp